package summer.util;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

import org.yaml.snakeyaml.Yaml;

import summer.Application;

/**
 * @author JIANG ZHEN X6978
 * @since  2020年7月10日 下午4:12:00
 *
 *
 */
public class YmlUtils {


    public static Application getApplication() {

        Application app = null;
        InputStream is = null;
        try {
            Yaml yml = new Yaml();
            String path = Object.class.getResource("/").getPath().substring(1)
                    + "application.yml";
            is = new FileInputStream(path);
            app = yml.loadAs(is, Application.class);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return app;
    }
}
